package com.hst.capacity.infra.convertor;

import com.hst.capacity.domain.model.entity.franchisee.FranchiseeUserEntity;
import com.hst.capacity.domain.model.request.franchisee.FranchiseeUserParam;
import com.hst.capacity.domain.model.response.PagingResultVO;
import com.hst.capacity.domain.model.response.franchisee.FranchiseeUserVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.ReportingPolicy;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * 用户的POJO属性转换器
 *
 * @author Hans
 */
@Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface UserConvertor {

    UserConvertor INSTANCE = Mappers.getMapper(UserConvertor.class);

    /**
     * 添加运力商账号入参转实体
     */
    @Mapping(target = "user.username", source = "username")
    @Mapping(target = "user.mobile", source = "mobile")
    @Mapping(target = "user.userStatus", source = "userStatus")
    @Mapping(target = "user.userType", source = "userType")
    @Mapping(target = "displayName", source = "realName")
    FranchiseeUserEntity convert(FranchiseeUserParam param);

    /**
     * 实体转VO
     */
    @Mapping(target = "username", source = "user.username")
    @Mapping(target = "mobile", source = "user.mobile")
    @Mapping(target = "userStatus", source = "user.userStatus")
    @Mapping(target = "userType", source = "user.userType")
    FranchiseeUserVO convert(FranchiseeUserEntity entity);

    /**
     * 实体PagingResultVO转PagingResultVO
     */
//    @Mapping(target = "fullName", source = "franchiseeEntity.fullName") 无法使用
    PagingResultVO<FranchiseeUserVO> convert(PagingResultVO<FranchiseeUserEntity> list);
}
